hysop.tools.string_utils module

hysop.tools.string_utils.camel2snake(string)[source]

Convert a string from camel case to snake case.

hysop.tools.string_utils.framed_str(title, msg, c='=', at_border=2)[source]

Format a message to fit between two separation lines containing a title.

hysop.tools.string_utils.multiline_split(strdata, maxlen, split_sep, replace, newline_prefix=None)[source]

Utility function to split one line of a column representation of string data into smaller pieces:

Input data (strdata):

(s0 s1 s2 s3)

Output data:
[ (s0.0, s1.0, s2.0, s3.0),

(s0.1, —-, s2.1, s3.1), (—-, —-, s2.2, —-), (—-, —-, s2.3, —-) ]

According to splitting rules:

maxlen: maximum length of each column in characters split_sep: allowed characters to split, per column replace: replacement when the string is too short (here —-) newline_prefix: prefix for each newline split, per column

All string inputs can be of type str.

hysop.tools.string_utils.prepend(string, prefix)[source]

Append prefix after each line return in string.

hysop.tools.string_utils.strlen(s)[source]

Like length but replace unicode characters by space before applying len()

hysop.tools.string_utils.vprint_banner(msg, c='*', spacing=False, at_border=0)[source]

Print a message preceded and succeded by separation lines.